

<template tag="以下文档内容为hycli自动生成">
  <el-dialog
    v-model="conf.visible"
    v-if="conf.visible" 
    :title="title"
    :width="conf.width"
    draggable
    align-center="true"
    :close-on-click-modal="false"
  >
<el-form :model="form"  ref="form" :rules="rules_aaaby">
    <el-row>
    <el-col :span="12">
    <!-- {"index":7,"raw":"plan_id","name":"plan_id","cname":"PlanId","type":{"raw":"number(10)","name":"number","len":10,"dlen":0},"defValue":"0","allowNull":false,"constraints":["le","q","c","sl(dev_plan,-,#lob_id)","u","v","tp(readonly,u)"],"desc":{"raw":"研发计划","name":"研发计划"}} -->
     <!--研发计划 下拉控件 -->
    <el-form-item prop="plan_id" label="研发计划" label-width="100px" label-position="right">
      <el-select   @change="onChange_plan_id(form.plan_id,'dev_plan')" v-model="form.plan_id" style="width: 100%" filterable clearable
        placeholder="请选择研发计划" disabled >
        <el-option v-for="item in plan_idList" :key="item.value" :label="item.name" :value="item.value" />
      </el-select>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":8,"raw":"prod_id","name":"prod_id","cname":"ProdId","type":{"raw":"number(10)","name":"number","len":10,"dlen":0},"defValue":"","allowNull":true,"constraints":["le","q","c","u","v","sl(prod_requirement,@plan_id,#lob_id)","DP","tp(multiselect,q)","@change(name:name)"],"desc":{"raw":"产品需求","name":"产品需求"}} -->
     <!--产品需求 下拉控件 -->
    <el-form-item prop="prod_id" label="产品需求" label-width="100px" label-position="right">
      <el-select   @change="onChange_prod_id(form.prod_id,'prod_requirement')" v-model="form.prod_id" style="width: 100%" filterable clearable
        placeholder="请选择产品需求" >
        <el-option v-for="item in prod_idList" :key="item.value" :label="item.name" :value="item.value" />
      </el-select>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":9,"raw":"name","name":"name","cname":"Name","type":{"raw":"varchar2(48)","name":"varchar2","len":48,"dlen":0},"defValue":"","allowNull":false,"constraints":["l","le","q","c","u","v","rows(1)","lw(160)","DN","#like"],"desc":{"raw":"名称","name":"名称"}} -->
    <!--名称 输入控件 -->
    <el-form-item prop="name" label="名称" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.name"  maxlength="48" 
      :rows="1"  placeholder="请输入名称"  />
      </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":10,"raw":"priority","name":"priority","cname":"Priority","type":{"raw":"number(1)","name":"number","len":1,"dlen":0},"defValue":"0","allowNull":false,"constraints":["l","le","c","u","fq","sl(PRI)","lw(80)","tp(radio,c-u)","v","tp(tag,l)","color","show(m,l)"],"desc":{"raw":"优先级","name":"优先级"}} -->
    <el-form-item prop="priority" label="优先级" label-width="100px" label-position="right">
      <el-radio-group v-model="form.priority"   >
        <el-radio-button v-for="item in priorityList" :key="item.value" :label="item.value" >
            {{item.name}}
        </el-radio-button>
      </el-radio-group>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":11,"raw":"tstatus","name":"tstatus","cname":"Tstatus","type":{"raw":"number(2)","name":"number","len":2,"dlen":0},"defValue":"","allowNull":false,"constraints":["l","le","q","fq","c","u","sl","arc","tp(multiselect,q)","tp(radio)","v","color"],"desc":{"raw":"测试状态","name":"测试状态"}} -->
    <el-form-item prop="tstatus" label="测试状态" label-width="100px" label-position="right">
      <el-radio-group v-model="form.tstatus"   >
        <el-radio-button v-for="item in tstatusList" :key="item.value" :label="item.value" >
            {{item.name}}
        </el-radio-button>
      </el-radio-group>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":12,"raw":"master","name":"master","cname":"Master","type":{"raw":"number(8)","name":"number","len":8,"dlen":0},"defValue":"","allowNull":false,"constraints":["l","le","c","u","q","fq","sl(tmaster,-,#lob_id)","v","tp(radio)","lw(80)"],"desc":{"raw":"用例编写","name":"用例编写"}} -->
    <el-form-item prop="master" label="用例编写" label-width="100px" label-position="right">
      <el-radio-group v-model="form.master"   >
        <el-radio-button v-for="item in masterList" :key="item.value" :label="item.value" >
            {{item.name}}
        </el-radio-button>
      </el-radio-group>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":13,"raw":"executor","name":"executor","cname":"Executor","type":{"raw":"number(8)","name":"number","len":8,"dlen":0},"defValue":"","allowNull":false,"constraints":["l","le","c","u","q","fq","sl(tmaster,-,#lob_id)","v","tp(radio)","lw(80)","dne"],"desc":{"raw":"测试执行","name":"测试执行"}} -->
    <el-form-item prop="executor" label="测试执行" label-width="100px" label-position="right">
      <el-radio-group v-model="form.executor"   >
        <el-radio-button v-for="item in executorList" :key="item.value" :label="item.value" >
            {{item.name}}
        </el-radio-button>
      </el-radio-group>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":14,"raw":"case_count","name":"case_count","cname":"CaseCount","type":{"raw":"number(8)","name":"number","len":8,"dlen":0},"defValue":"0","allowNull":true,"constraints":["l","le","c","u","v","lw(60)"],"desc":{"raw":"用例数","name":"用例数"}} -->
    <!--用例数 输入控件 -->
    <el-form-item prop="case_count" label="用例数" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.case_count"  maxlength="8" 
      :rows="0"  placeholder="请输入用例数"  />
      </el-form-item>
    </el-col>
    <el-col :span="24">
    <!-- {"index":17,"raw":"content","name":"content","cname":"Content","type":{"raw":"varchar2(2000)","name":"varchar2","len":2000,"dlen":0},"defValue":"","allowNull":false,"constraints":["le","c","u","v","rows(6)"],"desc":{"raw":"内容","name":"内容"}} -->
    <!--内容 输入控件 -->
    <el-form-item prop="content" label="内容" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.content"  maxlength="2000" 
      :rows="6"  type="textarea" show-word-limit  placeholder="请输入内容"  />
      </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":18,"raw":"start_case_time","name":"start_case_time","cname":"StartCaseTime","type":{"raw":"date","name":"date","len":0,"dlen":0},"defValue":"","allowNull":false,"constraints":["bl","c","u","q","tp(daterange,q)","f(MM/dd)","v","tp(datetime,c-u,yyyy/MM/dd 09:00:00)","x"],"desc":{"raw":"开始时间","name":"开始时间"}} -->
    <!--开始时间 日期控件 -->
    <el-form-item prop="start_case_time" label="开始时间" label-width="100px" label-position="right">
      <el-date-picker style="width: 100%" v-model="form.start_case_time" clearable type="datetime"
        placeholder="请选择开始时间" format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss" 
         :default-time="new Date($theia.str.dateFormat(new Date(),'yyyy/MM/dd 09:00:00'))"/>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":19,"raw":"finish_case_time","name":"finish_case_time","cname":"FinishCaseTime","type":{"raw":"date","name":"date","len":0,"dlen":0},"defValue":"","allowNull":false,"constraints":["l","le","c","u","q","tp(daterange,q)","v","f(MM/dd)","tp(datetime,c-u,yyyy/MM/dd 09:00:00)","show(m,l)","x"],"desc":{"raw":"用例评审","name":"用例评审"}} -->
    <!--用例评审 日期控件 -->
    <el-form-item prop="finish_case_time" label="用例评审" label-width="100px" label-position="right">
      <el-date-picker style="width: 100%" v-model="form.finish_case_time" clearable type="datetime"
        placeholder="请选择用例评审" format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss" 
         :default-time="new Date($theia.str.dateFormat(new Date(),'yyyy/MM/dd 09:00:00'))"/>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":20,"raw":"start_test_time","name":"start_test_time","cname":"StartTestTime","type":{"raw":"date","name":"date","len":0,"dlen":0},"defValue":"","allowNull":false,"constraints":["l","le","c","u","q","tp(daterange,q)","v","f(MM/dd HH时)","tp(datetime,c-u,yyyy/MM/dd 09:00:00)","x"],"desc":{"raw":"开始测试","name":"开始测试"}} -->
    <!--开始测试 日期控件 -->
    <el-form-item prop="start_test_time" label="开始测试" label-width="100px" label-position="right">
      <el-date-picker style="width: 100%" v-model="form.start_test_time" clearable type="datetime"
        placeholder="请选择开始测试" format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss" 
         :default-time="new Date($theia.str.dateFormat(new Date(),'yyyy/MM/dd 09:00:00'))"/>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":21,"raw":"finish_test_time","name":"finish_test_time","cname":"FinishTestTime","type":{"raw":"date","name":"date","len":0,"dlen":0},"defValue":"","allowNull":false,"constraints":["l","le","c","u","q","tp(daterange,q)","v","f(MM/dd HH时)","tp(datetime,c-u,yyyy/MM/dd 18:00:00)","x","show(m,l)"],"desc":{"raw":"完成时间","name":"完成时间"}} -->
    <!--完成时间 日期控件 -->
    <el-form-item prop="finish_test_time" label="完成时间" label-width="100px" label-position="right">
      <el-date-picker style="width: 100%" v-model="form.finish_test_time" clearable type="datetime"
        placeholder="请选择完成时间" format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss" 
         :default-time="new Date($theia.str.dateFormat(new Date(),'yyyy/MM/dd 18:00:00'))"/>
    </el-form-item>
    </el-col>
    </el-row>
</el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="hide" icon="close">取消</el-button>
        <el-button type="primary" @click="save" icon="select">提交</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script>
import rtext from "@/views/cmpnts/rtext.vue"
export default {
  components: {
    rtext
},
  data() {
    return {
      conf: {
        visible: false,
        width:"60%",
        uploadPath:this.$theia.env.join("/file/upload"),
      },
      title:"修改测试任务",
rules_aaaby:{
    plan_id:[{required:true,message:"请输入研发计划",trigger: 'blur'}],
    prod_id:[{required:false,message:"请输入产品需求",trigger: 'blur'}],
    name:[{required:true,message:"请输入名称",trigger: 'blur'}],
    priority:[{required:true,message:"请输入优先级",trigger: 'blur'}],
    tstatus:[{required:true,message:"请输入测试状态",trigger: 'blur'}],
    master:[{required:true,message:"请输入用例编写",trigger: 'blur'}],
    executor:[{required:true,message:"请输入测试执行",trigger: 'blur'}],
    case_count:[{required:false,message:"请输入用例数",trigger: 'blur'}],
    content:[{required:true,message:"请输入内容",trigger: 'blur'}],
    start_case_time:[{required:true,message:"请输入开始时间",trigger: 'blur'}],
    finish_case_time:[{required:true,message:"请输入用例评审",trigger: 'blur'}],
    start_test_time:[{required:true,message:"请输入开始测试",trigger: 'blur'}],
    finish_test_time:[{required:true,message:"请输入完成时间",trigger: 'blur'}],
  },
    form:{
        plan_id:"",
        prod_id:"",
        name:"",
        priority:"",
        tstatus:"",
        master:"",
        executor:"",
        case_count:"",
        content:"",
        start_case_time:"",
        finish_case_time:"",
        start_test_time:"",
        finish_test_time:"",
    },
    plan_idList:[],
    prod_idList:[],
    priorityList:[],
    tstatusList:[],
    masterList:[],
    executorList:[],
    }
  },
  methods: {
    show(form) {
      this.conf.visible = true;
      this.loadEnums_aaaby()
      this.form = Object.assign(form,this.$route.params)
      this.get(form)
    },
      get(form){
        let that = this
        this.conf.loading = true
        let postForm = {}
        postForm.tsk_id = form.tsk_id
        this.$theia.http.get("/ws/test/task",postForm).then(res=>{
          that.form = Object.assign(that.form, res)
        //处理枚举重新绑定
          this.loadEnums_aaaby()
          that.conf.loading = false
        }).catch(res=>{
          let code = ((res||{}).response||{}).status||0
          let msg = `测试任务查询失败(${code})`
          that.$notify.error({title: '失败',message:msg ,duration:5000})
        })
    },
    save(){
        this.$refs.form.validate((v=>{
            if(v) this.onSave()
        }))
    },
    onSave(){
      let that = this
        let postForm = Object.assign({},this.form)
        this.$theia.http.put("/ws/test/task",postForm).then(res=>{
            that.$notify.success({title: '成功',message: '测试任务保存成功',duration:5000})
            that.$theia.enum.clear("test_task")
            that.$theia.enum.get("test_task")
            that.hide()
            that.$emit("onsaved")
        }).catch(res=>{
            let code = ((res||{}).response||{}).status||0
            let msg = `测试任务修改失败(${code})`
            that.$notify.error({title: '失败',message: msg,duration:5000})
        })
    },
    hide() {
      this.conf.visible = false;
      this.$refs.form.resetFields();
    },
     onUploadSuccess(response){
    },
    onChange_plan_id(val,tp){
      if(this.conf.loading || !val||!this.form.plan_id){
        return
      }
      if (!val) {
        this.prod_idList = []
        return
      }
      this.prod_idList = this.$theia.enum.get("prod_requirement",val,this.$theia.user.get("lob_id"))||[]
      this.onChange_prod_id(this.form.prod_id,"prod_requirement")
      //添加联动
    },
    onChange_prod_id(val,tp){
      if(this.conf.loading || !val||!this.form.prod_id){
        return
      }
      //添加联动
      let that = this
      if(tp){
        let lst= this.$theia.enum.get(tp)
        var hasValues = {}
        lst.forEach(el => {
          if(el.value == val)
          if (!that.form.name || !that.form._name || that.form._name == that.form.name) {
            hasValues.name = true
            that.form.name = el.name
            that.form._name = el.name
          }
        });
        if(!hasValues.name){
          that.form._name = that.form.name
        }
      }
    },
    loadEnums_aaaby(){
        //研发计划
        this.plan_idList = this.$theia.enum.get("dev_plan","",this.$theia.user.get("lob_id"),false,"")
        //产品需求
        this.prod_idList = this.$theia.enum.get("prod_requirement",((this.form_aaaby||this.form).plan_id||"")+"",this.$theia.user.get("lob_id"),false,"")
        //优先级
        this.priorityList = this.$theia.enum.get("PRI","","" ,false,"")
        //测试状态
        this.tstatusList = this.$theia.enum.get("tstatus","","" ,false,"")
        //用例编写
        this.masterList = this.$theia.enum.get("tmaster","",this.$theia.user.get("lob_id"),false,"")
        //测试执行
        this.executorList = this.$theia.enum.get("tmaster","",this.$theia.user.get("lob_id"),false,"")
    },

  },
};
</script>

<style scoped>
.form_item_info{
  margin-left: 4px;
  color:#999;
}
.form_item_info:hover{
  cursor: pointer;
  font-weight: 500;
  color:#333;
}
</style>